//
//  UIButton+Extension.swift
//  HJWeibo
//
//  Created by mac on 16/1/16.
//  Copyright © 2016年 mac. All rights reserved.
//

import UIKit

extension UIButton {
    
    //指定背景图片 和按钮的图片的构造函数
    convenience init(imageName: String,backImageName: String) {
        
        self.init()
        setImage(UIImage(named: imageName), forState: .Normal)
        setImage(UIImage(named: imageName + "highlighted"), forState: .Highlighted)
        setBackgroundImage(UIImage(named: backImageName), forState: .Normal)
        setBackgroundImage(UIImage(named: backImageName + "_highlighted"), forState: .Highlighted)
//
        //指定大小
        sizeToFit()
    }
    
    
    //
    convenience init(title: String,fontSize: CGFloat,color: UIColor,backImageName: String) {
        
        self.init()
        //设置按钮文字
        setTitle(title, forState: .Normal)
        titleLabel?.font = UIFont.systemFontOfSize(fontSize)
        setTitleColor(color, forState: .Normal)
        setBackgroundImage(UIImage(named: backImageName), forState: .Normal)
        
    }
   
    
}